#ifndef _IO
    #include "io.h"
#endif

#define _XML

#ifdef _STANDALONE
	#include <stdio.h>
	#include <stdlib.h>
#endif
#include <libxml/xmlreader.h>
#include <libxml/parser.h>
#include <libxml/tree.h>


//END Tags 
#define TAG_END_NODE "SEG"
#define TAG_END_FEXP "FEXP"
#define TAG_END_FIMP "FIMP"
#define TAG_END_LREXP "LREXP"
#define TAG_END_LRIMP "LRIMP"
#define TAG_END "END"
//WORD TYPE TAG
#define TAG_WRD "WORD"

//END attributes
#define ATRIB_END_ID "id"
#define ATRIB_END_PARENT "parent"
#define ATRIB_END_COMPST "compst"
#define ATRIB_END_ROOT "root"
#define ATRIB_END_POS "pos"
#define ATRIB_END_ORDEM "ordem"

//Word attributes 
#define ATRIB_WRD_TRM "termo"
#define ATRIB_WRD_FS "fs"
#define ATRIB_WRD_END "end"
#define ATRIB_WRD_REL "relacao"
#define ATRIB_WRD_ANT "antecedente"
#define ATRIB_WRD_GEN "genero"
#define ATRIB_WRD_NUM "numero"
#define ATRIB_WRD_GRA "grau"

int _extracted_words_count;

word _read_word_from_xml(xmlNodePtr node);

gdsl_list_t _read_word_list_from_xml(xmlNodePtr node);

Segmento _read_end_segment_from_xml(xmlNodePtr a_node);

End _create_end_from_xml(xmlNodePtr a_node);

//input functions

End end_read_from_xml(char * xmlfilename);



char *word_to_xml_string(word w); 

void word_serialize_as_xml(word w, FILE * outfile);

int write_xml_node(End tree , void * user_data);

int write_full_xml_node(End tree,  void * user_data);

void end_serialize_as_xml(End tree , FILE * outfile);

void endio_dump_index(End tree , FILE* file);


